package com.easylinkin.linkappapi.openapi.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.easylinkin.linkappapi.lobar.entity.emp.EmpUserBase;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;

import com.easylinkin.linkappapi.openapi.dto.*;
import com.easylinkin.linkappapi.safe.dto.SafetyCheckCategory;
import com.easylinkin.linkappapi.safe.dto.SafetyCheckTrendDTO;
import com.easylinkin.linkappapi.safe.entity.DangerousInfo;
import com.easylinkin.linkappapi.webcammanage.entity.DeviceAttributeStatus;
import org.springframework.transaction.annotation.Transactional;
import com.easylinkin.linkappapi.device.entity.Device;
import com.easylinkin.linkappapi.tenant.entity.LinkappTenant;
import site.morn.rest.RestMessage;

/**
 * <p>开放API服务</p>
 *
 * @author TongJie
 * @since 2020/10/12 15:08
 */

public interface OpenApiService {


    List<DeviceByProject> getDevicesByProject(String projectId, int page) throws UnsupportedEncodingException;

    /**
     * 实时监控视频流推送-节流优化请求
     * @param deviceCode
     * @return
     * @throws UnsupportedEncodingException
     */
    VideoLimitDTO getVideoLimitDTOByDeviceCode(String deviceCode) throws UnsupportedEncodingException;

    List<DeviceUnitDTO> getDeviceUnitWithDeviceModel() throws UnsupportedEncodingException;

    List<com.easylinkin.linkappapi.openapi.dto.DeviceUnit> getDeviceUnitByProject() throws UnsupportedEncodingException;

    List<com.easylinkin.linkappapi.openapi.dto.DeviceUnit> getDeviceUnitByProject(LinkappTenant tenant) throws UnsupportedEncodingException;

    List<DeviceType> getDeviceTypeList() throws UnsupportedEncodingException;

    void updateDeviceInstall(Device device);

    /**
     * 查找linkthings 活动的应用； 同步修改AEP的租户状态
     */
    void synchronizeTenantStatusFromLinkthings() throws UnsupportedEncodingException;

    void getTenantInfo() throws UnsupportedEncodingException;

    Boolean updateTenantAccount(LinkappTenant tenant, String account, String newAccount) throws UnsupportedEncodingException;

    @SuppressWarnings("rawtypes")
    ApiDownResultDTO dataDown(Map dto) throws IOException;

    /**
     * 新增设备
     *
     * @param deviceList 设备列表
     */
    @Transactional(rollbackFor = Exception.class)
    void addDevices(List<Device> deviceList);

    /**
     * 批量擦除设备位置等信息
     *
     * @param deviceList 设备列表
     */

    @Transactional(rollbackFor = Exception.class)
    void batchEraseDevicePositionEtcInfo(Set<String> deviceList);
    

    /**
     * 埋点添加
     */
    void insertBuriedPoint(BuriedPointDTO buriedPointDTO) throws UnsupportedEncodingException, Exception;

    /***
     * 获取项目信息
     * @param project
     * @return
     */
    RestMessage getProjectInfo(String project);

    /***
     * 获取项目信息
     * @param innerProjectModel
     * @return
     */
    RestMessage getProjectInfo(InnerProjectModel innerProjectModel);

    /***
     * 删除aep
     * @return
     */
    void deleteAep(Long projectId);

    /**
     * 用户信息同步到linkthings
     * @param empUserBase
     * @return
     * @throws IOException
     */
    ApiDownResultDTO syncUser(EmpUserBase empUserBase);

    IPage<DeviceAttributeStatus> getDeviceVideoList(Long projectId);

    /**
     *
     * @param projectId
     * @return
     */
    LinkappTenant getAepTenantInfo(Long projectId);

    List<CameraCountByProjectDTO> getCameraCountByProjectIds(List<Long> projectIds);

    /**
     * 企业级大屏 检查台账趋势图
     *
     * @return
     */
    Map<String, List<SafetyCheckTrendDTO>> selectSafetyCheckTrend();

    /**
     * 企业级大屏-检查台账分布统计
     * @param start
     * @param end
     * @return
     */
    List<BigScreenStatisticDTO> selectSafetyCheckCategoryByName(Date start, Date end);

    /**
     * 企业级大屏-预警分布统计
     * @param start
     * @param end
     * @return
     */
    List<BigScreenStatisticDTO> selectAlarmStatistic(Date start, Date end);

    /**
     * 企业大屏-危大工程分类
     * @param dangerous
     * @return
     */
    List<BigScreenStatisticDTO> selectDangerousStatistic(DangerousInfo dangerous);

    /**
     * 近3月安全检查
     *
     * @return
     * @param startTime
     * @param endTime
     */
    SafetyCheckCategory selectSafetyCheckCategory(Date startTime, Date endTime);

    /**
     * 企业级大屏-项目列表统计查询
     * @param projectDTO
     * @return
     */
    List<ProjectStatisticDTO> selectProjectStatisticList(ProjectDTO projectDTO);
}

